<?php

namespace common\models\kaoguobao;

use Yii;
use common\models\BaseModels;
use yii\behaviors\TimestampBehavior;

class GoodsParams extends BaseModels
{

    const TYPE_NULL       = '';
    const TYPE_RADIO      = 'radio';
    const TYPE_LIST       = 'list';

    public static $type = [
        self::TYPE_NULL   => "不选择类型",
        self::TYPE_RADIO  => "radio",
        self::TYPE_LIST   => "list",
    ];

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%goods_params}}';
    }

    /**
     * 切换数据库(测试环境)
     */
    public static function getDb(){
        return Yii::$app->get('db_kgb');
    }

    /**
     * 给数据库的处理进行时间的操作
     */
    public function behaviors() {
        return [
            TimestampBehavior::className(),
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [[  'id',
                'is_valid',
                'key',
                'label',
                'title',
                'content',
                'sort',
                'type',
                'created_at',
                'updated_at',
            ], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id'            => Yii::t('app_table', 'ID'),
            'is_valid'      => Yii::t('app_table', '状态'),
            'type'          => Yii::t('app_table', '前端判断类型'),
            'title'         => Yii::t('app_table', '其他配置'),
            'label'         => Yii::t('app_table', '标题'),
            'content'       => Yii::t('app_table', '内容'),
            'key'           => Yii::t('app_table', '标识'),
            'sort'          => Yii::t('app_table', '排序'),
            'created_at'    => Yii::t('app_table', '创建时间'),
            'updated_at'    => Yii::t('app_table', '修改时间'),
        ];
    }
}
